<?php
namespace app\superAdmin\controller;
use \think\Controller;
use \think\Db;


class Template extends Controller 
{
	public function index()
    {
    	$templates = Db::name('template_ck')->select();
    	$this->assign("templateList",$templates);
        return $this->fetch();;
    }
    public function shield($id){
       
        $ustatenum=Db::name("template_ck")->where("tid='$id'")->value('tstate');

        if($ustatenum==0){
            if (Db::name("template_ck")->where("tid='$id'")->update(['tstate'=>1])) {
                $this->success('取消屏蔽成功');
            }else{
                $this->error('取消屏蔽失败');
            }

        }
        else{
            if (Db::name("template_ck")->where("tid='$id'")->update(['tstate'=>0])) {
                $this->success('屏蔽成功');
            }else{
                $this->error('屏蔽失败');
            }      
        }

	
	}
    public function find(){
        $findid=input('findid');
        $findstate=input('findstate');
        $findtratio=input('findtratio');

        if ($findid!=NULL) {
            $registration=Db::query("select * from `template_ck` where tid='$findid'");
            $this->assign("templateList",$registration);
            return $this->fetch("index");
        }elseif ($findstate!=NULL) {
            $registration=Db::query("select * from `template_ck` where tstate='$findstate'");
            $this->assign("templateList",$registration);
            return $this->fetch("index");
        }elseif ($findtratio!=NULL) {
            $registration=Db::query("select * from `template_ck` where ttratio='$findtratio'");
            $this->assign("templateList",$registration);
            return $this->fetch("index");
        }else{
            $registration=Db::query("select * from `template_ck`");
            $this->assign("templateList",$registration);
            return $this->fetch("index");
        }
    }

}